package org.meb.speedway.model.registry;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.persistence.Version;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@Entity
@Table(name = "t_league", uniqueConstraints = @UniqueConstraint(name = "LEAG_NAME_UK",
		columnNames = "name"))
@Getter
@Setter
@ToString(exclude = "teamsHistory")
public class League {

	@Id
	@Column(length = 20)
	private String code;

	@Version
	private Long version;

	@Column(length = 100, nullable = false)
	private String name;

	@OneToMany(mappedBy = "league", cascade = CascadeType.ALL)
	private List<LeagueTeamHistory> teamsHistory;
}
